//
//  ScoringView.m
//  phmall
//
//  Created by admin on 2017/10/9.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "ScoringView.h"

@interface ScoringView ()<XHStarRateViewDelegate>
@property(nonatomic,strong)UIView *headView;

@end
@implementation ScoringView

-(instancetype)init{
    if (self=[super init]) {
        self.headView=[[UIView alloc]init];
        self.backgroundColor=[UIColor whiteColor];
        [self addSubview:self.headView];
        self.headView.backgroundColor=[UIColor whiteColor];
        [self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self);
            make.top.equalTo(self);
            make.height.offset(44);
        }];
        
        UIImageView *icon=[[UIImageView alloc]init];
        [self.headView addSubview:icon];
        icon.image=[UIImage imageNamed:@"店铺-1"];
        [icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.headView).offset(20);
            make.centerY.equalTo(self.headView);
            make.width.height.offset(25);
        }];
        
        UILabel *name=[[UILabel alloc]init];
        [self.headView addSubview:name];
        name.text=@"店铺评分";
        name.font=[UIFont systemFontOfSize:16];
        [name mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(icon.mas_right).offset(10);
            make.centerY.equalTo(self.headView);
        }];
        
        UIView *line=[[UIView alloc]init];
        line.backgroundColor=[UIColor groupTableViewBackgroundColor];
        [self addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(10);
            make.right.equalTo(self).offset(-10);
            make.top.equalTo(name.mas_bottom).offset(10);
            make.height.offset(1);
        }];
        
        UILabel *describe=[[UILabel alloc]init];
        [self addSubview:describe];
        describe.text=@"商品描述:";
        describe.font=[UIFont systemFontOfSize:15];
        [self addSubview:describe];
        [describe mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(20);
            make.top.equalTo(name.mas_bottom).offset(20);
        }];

        self.describeStar = [[XHStarRateView alloc] initWithFrame:CGRectMake(20, 60, 200, 20)];
        self.describeStar.isAnimation = YES;
        self.describeStar.rateStyle = IncompleteStar;
        self.describeStar.tag = 1;
        self.describeStar.delegate = self;
        [self addSubview:self.describeStar];
        [self.describeStar mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(describe.mas_right).offset(20);
            make.right.equalTo(self).offset(-20);
            make.centerY.equalTo(describe).offset(-1);

            make.height.offset(20);
        }];
        
        UILabel *logistics=[[UILabel alloc]init];
        [self addSubview:logistics];
        logistics.text=@"物流服务:";
        logistics.font=[UIFont systemFontOfSize:15];
        [self addSubview:logistics];
        [logistics mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(20);
            make.top.equalTo(describe.mas_bottom).offset(20);
        }];

        self.logisticsStar = [[XHStarRateView alloc] initWithFrame:CGRectMake(20, 60, 200, 20)];
        self.logisticsStar.isAnimation = YES;
        self.logisticsStar.rateStyle = IncompleteStar;
        self.logisticsStar.tag = 1;
        self.logisticsStar.delegate = self;
        [self addSubview:self.logisticsStar];
        [self.logisticsStar mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(logistics.mas_right).offset(20);
            make.right.equalTo(self).offset(-20);
            make.centerY.equalTo(logistics).offset(-1);
            make.height.offset(20);
        }];
        
        UILabel *service=[[UILabel alloc]init];
        [self addSubview:service];
        service.text=@"客服评价:";
        service.font=[UIFont systemFontOfSize:15];
        [self addSubview:service];
        [service mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(20);
            make.top.equalTo(logistics.mas_bottom).offset(20);
        }];
        
        self.serviceStar = [[XHStarRateView alloc] initWithFrame:CGRectMake(20, 60, 200, 20)];
        self.serviceStar.isAnimation = YES;
        self.serviceStar.rateStyle = IncompleteStar;
        self.serviceStar.tag = 1;
        self.serviceStar.delegate = self;
        [self addSubview:self.serviceStar];
        [self.serviceStar mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(service.mas_right).offset(20);
            make.right.equalTo(self).offset(-20);
            make.centerY.equalTo(service).offset(-1);
            make.height.offset(20);
        }];
    }
    return self;
}
-(void)starRateView:(XHStarRateView *)starRateView currentScore:(CGFloat)currentScore{
    NSLog(@"%ld----  %f",starRateView.tag,currentScore);
}
@end
